<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:replace="dashboard/header :: header"></head>
<body>

	<!--
@desc  添加
@author WeiXiaoJin
@since 2020-01-21 10:44:46
-->
	<div layout:fragment="content">
		<div class="container-fluid content-main">
			<div class="animated fadeIn">
				<div class="row">
					<!-- /.col-->
					<div class="col-sm-12">
						<div class="card">
							<div class="card-body">
								<form class="form-horizontal" id="addForm">
									<div class="form-group row">
										<label class="col-md-2 col-form-label control-label"
											for="text-input">模型名称</label>
										<div class="col-md-9">
											<input class="form-control" id="name" type="text"
												name="name" placeholder="">
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-2 col-form-label control-label"
											for="text-input">模型主键</label>
										<div class="col-md-9">
											<input class="form-control" id="key" type="text"
												name="key" placeholder="">
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-2 col-form-label control-label"
											for="text-input">模型描述</label>
										<div class="col-md-9">
											<input class="form-control" id="description" type="text"
												name="description" placeholder="">
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
					<!-- /.col-->
				</div>
			</div>
		</div>

	</div>

	<footer th:replace="dashboard/footer :: footer"></footer>

	<script type="text/javascript">
		var addForm = $("#addForm");
		$(function() {
			addForm.validate({
				ignore : [],
				rules : {
					key : {
						required : true
					},
					name : {
						required : true
					},
					description : {
						required : true
					}
				}
			});
		});

		function submitHandler() {
			var result = $.validate.form("addForm");
			if (result) {
				// $.modal.openFull("新建工作流模型", url);
				
				var saveUrl = ctx + "activiti/module/generator";
				$.operate.save(saveUrl, addForm.serialize() , function(response){
					console.log("this is a test") ; 
					
					// 打开新的窗口
					if(response.code == 200){
						var url = ctx + "activiti/module/create?modelId="+response.data ; 	
						var index = top.layer.open({
		            		type: 2,
		            		fix: false,
		            		maxmin: false ,
		            		shade: 0.3,
		            		title: null , // "新建工作流模型",
		            		content: url,
		            		shadeClose: true,
		            	    cancel: function(index) {
		            			alert("index = " + index) ;
		            	    }
		            	});
		                top.layer.full(index);
					}else{
						$.model.msg("创建模型错误.") ; 
					}
				});
			}
		}
	</script>

</body>
</html>


